﻿//--------------------------------------------------------------------//
//	   此代码由代码生成器自动生成									  //
//	   生成时间 2021-05-19 15:00:46 	                              //
//	   描述：库存盘点表明细
//--------------------------------------------------------------------//

using System;
using FluentValidation;
using RayD.Core;

namespace RayD.WebApi.Models.Interact
{
    public class RX_AdjustmentListModel : BaseModel
    {
        #region 实体成员
        /// <summary>
        /// 海关：VCCID 商品编码公服：materialNo 商品SKU编码
        /// </summary>
        /// <returns></returns>
        public string Vccid { get; set; }
        /// <summary>
        /// 海关：CHSCD HS编码公服：goodsNo 商品编码，对应HS编码
        /// </summary>
        /// <returns></returns>
        public string Chscd { get; set; }
        /// <summary>
        /// 海关：CCNNM 商品中文名公服：goodsName 商品名称
        /// </summary>
        /// <returns></returns>
        public string Ccnnm { get; set; }
        /// <summary>
        /// 海关：CENNM 商品英文名
        /// </summary>
        /// <returns></returns>
        public string Cennm { get; set; }
        /// <summary>
        /// 海关：OPERATION 操作类型 【参数表】01核增02核减公服：OPERATION操作类型 1-增加库存 2-扣减库存
        /// </summary>
        /// <returns></returns>
        public string Operation { get; set; }
        /// <summary>
        /// 海关：OPNUM 调整数量公服：quantity 调整数量
        /// </summary>
        /// <returns></returns>
        public int? Opnum { get; set; }
        /// <summary>
        /// 公服：ORIGINCOUNTRY 原产国代码，和海关进⼝时的国家 代码⼀致
        /// </summary>
        /// <returns></returns>
        public string Origincountry { get; set; }
        /// <summary>
        /// 公服：BRANDNAME 商品品牌
        /// </summary>
        /// <returns></returns>
        public string Brandname { get; set; }
        /// <summary>
        /// 公服：MODEL 商品型号
        /// </summary>
        /// <returns></returns>
        public string Model { get; set; }
        /// <summary>
        /// 公服：BARCODE 商品条码
        /// </summary>
        /// <returns></returns>
        public string Barcode { get; set; }
        /// <summary>
        /// 公服：RFIDS 商品RFID标签，多个英⽂逗号分 隔
        /// </summary>
        /// <returns></returns>
        public string Rfids { get; set; }
        /// <summary>
        /// 公服：QUANTITYUNITCODE 商品数量单位编码 
        /// </summary>
        /// <returns></returns>
        public string Quantityunitcode { get; set; }
        /// <summary>
        /// 公服：LEGALUNITCODE 法定计量单位 
        /// </summary>
        /// <returns></returns>
        public string Legalunitcode { get; set; }
        /// <summary>
        /// 公服：LEGALQUANTITY 法定数量
        /// </summary>
        /// <returns></returns>
        public int? Legalquantity { get; set; }
        /// <summary>
        /// 公服：SECONDLEGALUNITCODE 第二法定单位，参考HS编码的第二法定单位
        /// </summary>
        /// <returns></returns>
        public string Secondlegalunitcode { get; set; }
        /// <summary>
        /// 公服：SECONDLEGALQUANTITY 第⼆法定数量，第⼆法定单位有内 容时，此值必填
        /// </summary>
        /// <returns></returns>
        public int? Secondlegalquantity { get; set; }
        /// <summary>
        /// 公服：WEIGHTUNITCODE 重量计量单位
        /// </summary>
        /// <returns></returns>
        public string Weightunitcode { get; set; }
        /// <summary>
        /// 公服：GROSSWEIGHT 商品重和
        /// </summary>
        /// <returns></returns>
        public decimal? Grossweight { get; set; }
        /// <summary>
        /// 公服：NETWEIGHT 商品净重和
        /// </summary>
        /// <returns></returns>
        public decimal? Netweight { get; set; }
        /// <summary>
        /// 公服：FEATURE JSON格式的扩展字段，具体内 容，后续业务场景约定
        /// </summary>
        /// <returns></returns>
        public string Feature { get; set; }
        #endregion

        /// <summary>
        /// 业务参数验证
        /// </summary>
        /// <returns></returns>
        public override (bool, string) CheckParameter()
        {
            return base.CheckParameter(new RX_AdjustmentListModelValidator().Validate(this));
        }
    }

    /// <summary>
    /// 模型验证
    /// </summary>
    public class RX_AdjustmentListModelValidator : AbstractValidator<RX_AdjustmentListModel>
    {
        public RX_AdjustmentListModelValidator()
        {
            RuleFor(x => x.Secondlegalquantity).NotEmpty().WithMessage("第⼆法定数量不能为空！").When(c => !c.Secondlegalunitcode.IsEmpty());
        }

        private bool ValidateQty2(RX_AdjustmentListModel model, int? value)
        {
            bool res = true;
            if (!model.Secondlegalunitcode.IsEmpty())
            {
                res = !value.IsEmpty();
            }
            return res;
        }
    }
}

